// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-11-22

// last update 2005-8-11 luxizhu

#ifndef __MENU_H_COMMON_UI__
#define __MENU_H_COMMON_UI__

#pragma once

#pragma once
#include "listview.h"

class CJoyMenu;

//##ModelId=44CF17B60234
class CJoyMenuItem : public CJoyListViewItem
{
public:
	//##ModelId=44CF17B60244
    CJoyImagePtr    m_icon;
	//##ModelId=44CF17B60249
    CStringW        m_text;
	//##ModelId=44CF17B6024D
    UINT            m_id;

	//##ModelId=44CF17B6024E
    virtual void CM_MouseLeave();
	//##ModelId=44CF17B60252
    virtual void CM_MouseHover();
	//##ModelId=44CF17B60254
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
	//##ModelId=44CF17B60258
    virtual void CM_Draw(Graphics& graph);

public:
	//##ModelId=44CF17B60263
    CJoyMenuItem();
	//##ModelId=44CF17B60264
    virtual ~CJoyMenuItem();

	//##ModelId=44CF17B60271
    CJoyMenu* GetMenu()
    {
        return (CJoyMenu*)m_listView;
    }
};

//##ModelId=44CF17B60290
class CJoyMenu :
    public CJoyListView
{
	DECLARE_DYNAMIC(CJoyMenu)
protected:

	//##ModelId=44CF17B60295
    static CJoyMenu* m_hookMenu;
	//##ModelId=44CF17B60297
    static HHOOK    m_mouseHook;
	//##ModelId=44CF17B6029F
    static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);

	//##ModelId=44CF17B602A4
    CJoyMenuItem* CreateItem();
	//##ModelId=44CF17B602AF
	void SetBorder(HWND hWnd,BOOL bBorder);

	//##ModelId=44CF17B602B2
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);
public:
	//##ModelId=44CF17B602BF
    int m_iconMargin;
	//##ModelId=44CF17B602C0
    int m_iconSize;
	//##ModelId=44CF17B602C1
    int m_textMargin;
	//##ModelId=44CF17B602C2
	int m_nTrackedID;
public:
	//##ModelId=44CF17B602C3
    CJoyMenu(void);
	//##ModelId=44CF17B602CE
    virtual ~CJoyMenu(void);

	//##ModelId=44CF17B602D1
    bool Create();
	//##ModelId=44CF17B602D2
    void Show(int x, int y);
	
	//##ModelId=44CF17B602DF
	HANDLE CreatePopupMenu();
	//##ModelId=44CF17B602E0
	BOOL AppendMenu (UINT nFlags,UINT nIDNewItem = 0,LPCTSTR lpszNewItem = NULL);
	//##ModelId=44CF17B602F0
	BOOL AppendMenu (UINT nFlags,UINT nIDNewItem,const CBitmap* pBmp );
	//##ModelId=44CF17B602FD
	BOOL AppendMenu (UINT nFlags,UINT nIDNewItem,Image* pImage );
	//##ModelId=44CF17B6030D
	int TrackPopupMenu (UINT nFlags,int x,int y,CWnd* pWnd,LPCRECT lpRect = 0 ); 
	//##ModelId=44CF17B60313
	int TrackPopupMenuEx (UINT nFlags,int x,int y,CWnd* pWnd,LPCRECT lpRect = 0 ); 	

public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44CF17B60321
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	//##ModelId=44CF17B6032E
    afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	//##ModelId=44CF17B60332
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	//##ModelId=44CF17B6033C
    afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
	//##ModelId=44CF17B60341
    afx_msg void OnSize(UINT nType, int cx, int cy);
	//##ModelId=44CF17B6034B
    afx_msg void OnClose();
	//##ModelId=44CF17B6034D
	afx_msg void OnTimer(UINT nIDEvent);
	//##ModelId=44CF17B60350
	afx_msg void OnPaint();
	//##ModelId=44CF17B60352
	afx_msg void OnDestroy();
	//##ModelId=44CF17B60354
	int SelectID(void);
};

#endif  // __MENU_H_COMMON_UI__
